package com.motu.data;

import com.motu.vertx.module.utility.toolset.Tool;
import io.vertx.core.json.JsonObject;

/**
 * 用户登录设备信息
 */
public class UserLoginDevice {

	private int platform;// platform
	private int channel;// channel
	private String deviceId;// 设备ID
	private String accountId;// 账号ID
	private int serverId;// 服务器ID
	private String motuAdDeviceId;//魔兔广告设备ID
	private String motuAdDeviceType;//魔兔广告设备类型
	private String motuBiDeviceId;//魔兔BI设备ID
	private String tdDeviceId;//数数设备ID
	private String ryDeviceId;//热云设备ID
	private String distinctId;// 数数访客ID
	private String packageName;// 包名
	private String gateName;// 网关名称
	private String ip;// ip
	private String ryos;// 操作系统（例如iOS）
	private String timeZone;// 时区（例如8）
	private String idfa;// ios设备参数
	private String idfv;// ios设备参数
	private String imei;// 安卓设备参数
	private String oaid;// 安卓设备匿名标识符，详情参见：http://msa-alliance.cn/col.jsp?id=120
	private String androidId;// 安卓设备参数
	private String gpsAdid;// 谷歌广告ID
	private String ua;// 设备的user-agent
	private String caid;// ios广告参数，最新caid
	private String lastCaid;//ios广告参数，上个版本caid
	private String adid;// adjust返回的adid
	private String appVersion;// 应用版本号（例如1.9.2）
	private String operatingSystemVersion;// 数数返回的操作系统版本（例如18.1.1）
	private String ryosVersion;// 客户端获取的操作系统版本（例如18.1.1）
	private String deviceType;// 设备型号（例如iPhone15,3）
	private int simulator;// 模拟器（0否 1是）
	private String producer;// 手机生产商（例如Apple）
	private String operator;// 运营商
	private String networkType;// 网络类型（例如WIFI）
	private String buildSerial;// 硬件序列号

	/**
	 * 创建一个实例对象
	 *
	 * @param loginDeviceInfo 用户登录设备信息
	 * @return UserLoginDevice对象
	 */
	public static UserLoginDevice newInstance(JsonObject loginDeviceInfo) {
		if (loginDeviceInfo == null) {
			return null;
		} else {
			return new UserLoginDevice(loginDeviceInfo);
		}
	}

	public UserLoginDevice(JsonObject loginDeviceInfo) {
		this.platform = loginDeviceInfo.getInteger("platform", 0);
		this.channel = loginDeviceInfo.getInteger("channel", 0);
		this.deviceId = loginDeviceInfo.getString("deviceid", "");
		this.accountId = loginDeviceInfo.getString("accountId", "");
		this.serverId = loginDeviceInfo.getInteger("serverId", 0);
		this.motuAdDeviceId = loginDeviceInfo.getString("device_id_mt", "");
		this.motuAdDeviceType = loginDeviceInfo.getString("device_id_type_mt", "");
		this.motuBiDeviceId = loginDeviceInfo.getString("device_id_bi_mt", "");
		this.tdDeviceId = loginDeviceInfo.getString("device_id_td", "");
		this.ryDeviceId = loginDeviceInfo.getString("device_id_ry", "");
		this.distinctId = loginDeviceInfo.getString("distinct_id", "");
		this.packageName = loginDeviceInfo.getString("packagename", "");
		this.gateName = loginDeviceInfo.getString("gate_name", "");
		this.ip = loginDeviceInfo.getString("ip", "");
		this.ryos = loginDeviceInfo.getString("ryos", "");
		this.timeZone = loginDeviceInfo.getString("tz", "");
		this.idfa = loginDeviceInfo.getString("idfa", "");
		this.idfv = loginDeviceInfo.getString("idfv", "");
		this.imei = loginDeviceInfo.getString("imei", "");
		this.oaid = loginDeviceInfo.getString("oaid", "");
		this.androidId = loginDeviceInfo.getString("androidid", "");
		this.gpsAdid = loginDeviceInfo.getString("gps_adid", "");
		this.ua = loginDeviceInfo.getString("ua", "");
		this.caid = loginDeviceInfo.getString("caid", "");
		this.lastCaid = loginDeviceInfo.getString("last_caid", "");
		this.adid = loginDeviceInfo.getString("adid", "");
		this.appVersion = loginDeviceInfo.getString("app_version", "");
		this.operatingSystemVersion = loginDeviceInfo.getString("operating_system_version", "");
		this.ryosVersion = loginDeviceInfo.getString("ryosversion", "");
		this.deviceType = loginDeviceInfo.getString("rydevicetype", "");
		this.simulator = loginDeviceInfo.getInteger("simulator", 0);
		this.producer = loginDeviceInfo.getString("producer", "");
		this.operator = loginDeviceInfo.getString("operator", "");
		this.networkType = loginDeviceInfo.getString("network_type", "");
		this.buildSerial = loginDeviceInfo.getString("build_serial", "");

		// 兼容处理，如果取不到魔兔BI设备ID，则用数数的设备ID
		if (Tool.isEmpty(motuBiDeviceId)) {
			this.motuBiDeviceId = this.tdDeviceId;
		}
	}

	public int getPlatform() {
		return platform;
	}

	public int getChannel() {
		return channel;
	}

	public String getDeviceId() {
		return deviceId;
	}

	public String getAccountId() {
		return accountId;
	}

	public int getServerId() {
		return serverId;
	}

	public String getMotuAdDeviceId() {
		return motuAdDeviceId;
	}

	public String getMotuAdDeviceType() {
		return motuAdDeviceType;
	}

	public String getMotuBiDeviceId() {
		return motuBiDeviceId;
	}

	public String getTdDeviceId() {
		return tdDeviceId;
	}

	public String getRyDeviceId() {
		return ryDeviceId;
	}

	public String getDistinctId() {
		return distinctId;
	}

	public String getPackageName() {
		return packageName;
	}

	public String getGateName() {
		return gateName;
	}

	public String getIp() {
		return ip;
	}

	public String getRyos() {
		return ryos;
	}

	public String getTimeZone() {
		return timeZone;
	}

	public String getIdfa() {
		return idfa;
	}

	public String getIdfv() {
		return idfv;
	}

	public String getImei() {
		return imei;
	}

	public String getOaid() {
		return oaid;
	}

	public String getAndroidId() {
		return androidId;
	}

	public String getGpsAdid() {
		return gpsAdid;
	}

	public String getUa() {
		return ua;
	}

	public String getCaid() {
		return caid;
	}

	public String getLastCaid() {
		return lastCaid;
	}

	public String getAdid() {
		return adid;
	}

	public String getAppVersion() {
		return appVersion;
	}

	public String getOperatingSystemVersion() {
		return operatingSystemVersion;
	}

	public String getRyosVersion() {
		return ryosVersion;
	}

	public String getDeviceType() {
		return deviceType;
	}

	public int getSimulator() {
		return simulator;
	}

	public String getProducer() {
		return producer;
	}

	public String getOperator() {
		return operator;
	}

	public String getNetworkType() {
		return networkType;
	}

	public String getBuildSerial() {
		return buildSerial;
	}

}
